package edu.edu_realtime_publisher_second.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SugarMapper {

    @Select("select\n"
            +"    provinceName\n"
            +"    ,finalAmount \n"
            +"from dws_trade_province_tradesum_window\n"
            +"where toYYYYMMDD(stt) = #{date};")
    List<TradeProvinceAmount> selectTradeProvinceAmount(@Param("date") int date);

    @Select("select\n" +
            "    sourceName\n" +
            "    ,finalAmount\n" +
            "    ,personCount\n" +
            "    ,orderCount\n" +
            "from dws_trade_source_tradesum_window\n" +
            "where toYYYYMMDD(stt) = #{date};")
    List<TradeSourceTradeSum> selectTradeSourceSum(@Param("date") int date);

    @Select("select\n" +
            "    courseName\n" +
            "    ,personCt\n" +
            "    ,scoreAvg\n" +
            "    ,durationAvg \n" +
            "from \n" +
            "    dws_test_course_testpaper_window\n" +
            "where toYYYYMMDD(stt) = #{date}\n" +
            "and courseName is not null\n" +
            "order by scoreAvg desc limit #{limit}" +
            ";")
    List<TestCourseTestPaper> selectTestCourseTestPaper(@Param("date") int date,@Param("limit") int limit);

    @Select("select \n" +
            "    paperName\n" +
            "    ,scoreRange\n" +
            "    ,sum(personCt) personCt\n" +
            "    ,sum(paperCt) paperCt \n" +
            "from dws_test_scoreRang_testpaper_window \n" +
            "where toYYYYMMDD(stt) = #{date}\n" +
            "group by paperName,scoreRange\n"+
            "limit #{limit}" +
            ";")
    List<TestScoreRangeBean> selectTestScoreRange(@Param("date") int date,@Param("limit") int limit);
}
